package cn.maihe.elg.operation.supports.guarantee.enums;

import java.util.Arrays;

/**
 * @Description
 * @Author caixh
 * @Date 2021/5/19.
 */
public enum RespCode {

    SUCCESS("200", "明确成功"),
    FAILURE("400", "明确失败"),
    NO_PARAM("404", "参数缺失"),
    NO_DATA("405", "没有数据"),
    EXCEPTION("500", "异常错误"),

    INSPECT_NO("2702","保函不存在"),
    CHECK_FALSE("2605","无法识别该文件"),
    ;

    private String respCode;
    private String respDesc;

    RespCode(String respCode, String respDesc) {
        this.respCode = respCode;
        this.respDesc = respDesc;
    }

    public String getRespCode() {
        return respCode;
    }

    public String getRespDesc() {
        return respDesc;
    }

    public RespCode resolve(String respCode) {
        return Arrays.stream(values()).filter(v -> v.getRespCode().equals(respCode)).findFirst().orElseThrow(() -> new RuntimeException("未知响应码[" + respCode + "错误]"));
    }
}
